import java.util.*;
import java.math.*;

public class problem3 {
	
	static public void main(String[] params) {
		final long P = 600851475143L;
		int i,j;
		
		//Sieve of Eratosthenes
		boolean primes[] = new boolean[(int)Math.sqrt((double)P)+1];
		i = 2;
		for(i = 2; i < primes.length/2; i++)
			if(primes[i] == false)
				for(j=2*i; j<primes.length; j+=i)
					primes[j] = true;
		
		for(i=primes.length-1; i>1 && !(!primes[i] && P%i==0); i--);
		System.out.println(i);
	}
}

